#ifndef __PCF8563_H__
#define __PCF8563_H__

#include <time.h>
#include <stdbool.h>
#include "driver/i2c.h"

#define PCF8563_DEBUG 1

#define PCF8563_ADDR 0x51
#define PCF8563_ADDR_STATUS1 0x00
#define PCF8563_ADDR_STATUS2 0x01
#define PCF8563_ADDR_TIME 0x02
#define PCF8563_ADDR_ALARM 0x09
#define PCF8563_ADDR_CONTROL 0x0d
#define PCF8563_ADDR_TIMER 0x0e

#ifdef __cplusplus
extern "C"
{
#endif

    typedef enum
    {
        SEC,  /* !> 0-59 */
        MIN,  /* !> 0-59 */
        HOUR, /* !> 0-23 */
        MDAY, /* !> 1-31 */
        MON,  /* !> 1-12 */
        YEAR, /* !> 0-99 */
        WDAY, /* !> 0-6 */
    } pcf8563_get_data_type_t;

    uint16_t pcf8563_calculate_Weekday(uint16_t year, uint8_t month, uint8_t day);
    esp_err_t pcf8563_i2c_master_init(i2c_port_t port, int sda, int scl);
    esp_err_t pcf8563_set_time(uint8_t sec, uint8_t min, uint8_t hour, uint8_t mday, uint8_t wday, uint8_t mon, uint16_t year);
    uint16_t pcf8563_get_data(pcf8563_get_data_type_t data_type);
    void pcf8563_task(void *arg);

#ifdef __cplusplus
}
#endif

#endif
